package com.handpay.nocardpay.baselibrary.commbase.model.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * @author sxshi on 2017/4/25.
 *         email:emotiona_xiaoshi@126.com
 *         describe:Describe the function  of the current class
 */

public class BaseResponseBean implements Parcelable {
    public String responseCode;
    public String errMessage;

    public BaseResponseBean() {
    }

    public static final Creator<BaseResponseBean> CREATOR = new Creator<BaseResponseBean>() {
        @Override
        public BaseResponseBean createFromParcel(Parcel in) {
            return new BaseResponseBean(in);
        }

        @Override
        public BaseResponseBean[] newArray(int size) {
            return new BaseResponseBean[size];
        }
    };

    /**
     * 判断请求结果成功或者失败
     * 1、true 成功(流程继续)
     * 2、false 失败(流程中断)
     *
     * @return 判断接口数据正确与否
     */
    public boolean isRequstSuccess() {
        if (!TextUtils.isEmpty(responseCode) && !TextUtils.isEmpty(errMessage)) {
            return false;
        } else {
            return true;
        }
    }
    
    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.responseCode);
        dest.writeString(this.errMessage);
    }

    protected BaseResponseBean(Parcel in) {
        this.responseCode = in.readString();
        this.errMessage = in.readString();
    }

}
